package com.spa.interfaces.shop;

import com.spa.application.command.shop.SwitchFlagCommand;
import com.spa.application.dto.common.rule.RuleDto;
import com.spa.application.dto.shop.MineDTO;
import com.spa.application.service.shop.ShopMineService;
import com.spa.infrastructure.common.ResponseMessage;
import com.spa.interfaces.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/shop/mine")
public class ShopMineController extends BaseController {

    @Autowired
    private ShopMineService shopMineService;

    @PostMapping
    public ResponseMessage<MineDTO> index() {
        return responseHelper.success(shopMineService.index());
    }

    @PostMapping("queryShopRule")
    public ResponseMessage<List<RuleDto>> queryShopRule() {
        return responseHelper.success(shopMineService.queryShopRule());
    }

    @PostMapping("switchFlag")
    public ResponseMessage switchFlag(@RequestBody SwitchFlagCommand command) {
        shopMineService.switchFlag(command.getFlag());
        return responseHelper.success();
    }

}
